package com.tedu.bill1;

/**
 * Author：毕龙
 * Date: 2024/4/11 19:12
 */
public class Student {
    int age;
    String name;
    String sex;
    //将信用卡作为学生的属性
    private CreditCard cc;
    //无参的构造
    public Student(){
        System.out.println("执行无参的构造");
    }

    //有参构造
    public Student(int age){
        this();
        System.out.println("执行一个参数的构造");
    }

    //有参的构造
    public Student(int age,String name,String sex){
        //this();
        this(age);
        //初始化实例变量
        this.age = age;
        this.name = name;
        this.sex = sex;
        //执行无参的构造
        //Call to 'this()' must be first statement in constructor body
        //this();
    }
    public Student(int age,String name,String sex,CreditCard cc){

        //初始化实例变量
        this.age = age;
        this.name = name;
        this.sex = sex;
        this.cc = cc;

    }

    public void setCC(CreditCard cc){
        this.cc = cc;
    }
    public CreditCard getCC(){
        return cc;
    }

    //打印学生的信息
    public void print(){
        System.out.println("姓名："+name+"\t 年龄："+age +"\t 性别:"+sex);
    }

    public void study(){
        System.out.println("this地址："+this);
        System.out.println(this.name+"学习java");
        this.print();
        print();
    }

}
